{% extends "base.html" %}
{% import "bootstrap/wtf.html" as wtf %}
{% import "_macros.html" as macros %}

{% block title %}Fly-admin后台{% endblock %}

{% block navbar %}
<header class="main-header" style="position: fixed;top: 0px;width:100%;max-height:100px;z-index:1030"> <!-- 固定置顶 -->
    <a href="{{ url_for('main.index') }}" class="logo">
      <!-- mini logo for sidebar mini 50x50 pixels -->
      <span class="logo-mini"><b>F</b>ly</span>
      <!-- logo for regular state and mobile devices -->
      <span class="logo-lg"><b>梦开始的地方</b></span>
    </a>
    <nav class="navbar navbar-static-top" role="navigation">
    <a href="#" class="sidebar-toggle" data-toggle="offcanvas" role="button">
    <span class="sr-only">Toggle navigation</span>
    </a>
          <div class="navbar-header">            
            <ul class="nav navbar-nav">
            <li><a href="{{ url_for('main.index') }}">回到主页</a></li>
            </ul> 
          </div>
    </nav>                       
</header>

<aside class="main-sidebar" style="position: fixed;left: 0px;">　
<!-- 左侧拉伸栏 -->
  <section class="sidebar">
    <form action="{{url_for('main.search')}}" method="post" class="sidebar-form">
        <div class="input-group">
        {{g.search_form.hidden_tag()}}
        <input type="text" name="search" class="form-control" placeholder="Search blog">
         <span class="input-group-btn">
          <button type="submit"  id="search-btn" class="btn btn-flat"><i class="fa fa-search"></i></button>
         </span>
        </div>
    </form>
<!--     <ul class="sidebar-menu">
    <li class="header"><h4>&nbsp;输入标题搜索文章</h4></li> 
    </ul> -->

<!--     <form style="display: inline;" action="{{url_for('main.search')}}" method="post" name="search">
    {{g.search_form.hidden_tag()}}{{g.search_form.search(size=20)}}<input type="submit" value="按标题搜索" placeholder="Search...">
    </form> -->


    <ul class="sidebar-menu">
      <!-- <li class="header">推荐</li>  -->

       
      <li class="treeview">                      
          <a href="#"><i class="fa fa-circle-o text-aqua"></i> <span>全部分类</span> <i class="fa fa-angle-left pull-right"></i></a>          
          <ul class="treeview-menu" style="display: block;">
          {% for category in g.categorys %}
            <li><a href= "{{ url_for('main.category', id=category.id) }}">{{category.name}}({{category.posts.count()}})</a></li>
          {% endfor %} 
          </ul>          
      </li>

      <li class="treeview">
        <a href="#"><i class="fa fa-circle-o text-red"></i> <span>热门文章</span> <i class="fa fa-angle-left pull-right"></i></a>
        <ul class="treeview-menu" style="display: block;">
          <li><a href="{{ url_for('main.post', id=g.hot_post[0].id) }}">No1. {{g.hot_post[0].head}}</a></li>
          <li><a href="{{ url_for('main.post', id=g.hot_post[1].id) }}">No2. {{g.hot_post[1].head}}</a></li>
          <li><a href="{{ url_for('main.post', id=g.hot_post[2].id) }}">No3. {{g.hot_post[2].head}}</a></li>
          <li><a href="{{ url_for('main.post', id=g.hot_post[3].id) }}">No4. {{g.hot_post[3].head}}</a></li>
          <li><a href="{{ url_for('main.post', id=g.hot_post[4].id) }}">No5. {{g.hot_post[4].head}}</a></li>
          <li><a href="{{ url_for('main.post', id=g.hot_post[5].id) }}">No6. {{g.hot_post[5].head}}</a></li>
          <li><a href="{{ url_for('main.post', id=g.hot_post[6].id) }}">No7. {{g.hot_post[6].head}}</a></li>
          <li><a href="{{ url_for('main.post', id=g.hot_post[7].id) }}">No8. {{g.hot_post[7].head}}</a></li>
<!--                 最长26字    -->         
        </ul>
      </li>  
      <li><a href="#top"><i class="fa fa-share"></i> <span>回到顶部</span></a></li> 
    </ul>        
  </section>
</aside>  
{% endblock %}


{% block contenthead %}
{{ super() }}
<section class="content-header" >
<!--   <h1>
    Dashboard
    <small>Control panel</small>
  </h1> -->
  <ol class="breadcrumb">
    <li><a href="{{ url_for('main.index') }}"><i class="fa fa-fw fa-home"></i>首页</a></li>    
    <li class="active"><a href="#">网站后台</a></li>
  </ol>
</section>
{% endblock %}


{% block page_content %}

{{super()}}

{% if current_user.is_administrator() %}
<h1><strong> {{ current_user.username }},欢迎来到Blog后台 </strong><small>{{ moment(g.current_time).format('LLL') }}</small></h1>

<!--     <p>That was {{ moment(g.current_time).fromNow(refresh=True) }}</p>
<script >
document.write("现在是"+(new Date()).toLocaleDateString() + " " + (new Date()).toLocaleTimeString());     
// 时间
</script>  -->
<div class="btn-group">
<a href="{{ url_for('admin.edit') }}" class="btn btn-info" >后台管理员</a>
<a href="{{ url_for('admin.edituser') }}" class="btn btn-default">所有用户</a>
<a href="{{ url_for('admin.editpost') }}" class="btn btn-default">文章管理</a>
<a href="{{ url_for('admin.editcategory') }}" class="btn btn-default">分类管理</a>
<a href="{{ url_for('admin.editcomment') }}" class="btn btn-default">评论管理</a>
</div>
</br>


<h3><strong>后台管理员列表</strong>
<a href="{{ url_for('admin.addadmin') }}">&nbsp;<small>添加管理员</small><i class="fa fa-plus"></i></a>

</h3>
<div class="row">
 <div class="col-xs-12">
    <div class="box-body table-responsive no-padding">
      <table class="table table-hover">
        <tr>
          <th>管理员</th>          
          <th>注册时间</th>
          <th>操作</th>          
        </tr>
        {% for user in admins %}
        <tr>
          {% if user.username  %}
	          <td><a href="{{ url_for('main.user',username=user.username) }}">{{ user.username }}</a></td>          
	          <td>{{ moment(user.member_since).format('L') }}</td>          
	          {% if user != current_user %}
		          <td><a href="{{ url_for('admin.admin2user',id=user.id) }}" class="label label-danger">
		              降为普通用户
		              </a>
		          </td>
	          {% else %}
		          <td><a href="#" class="label label-default">
		              花式作死
		              </a>
		          </td>
	          {% endif %}
	      {% endif %}
        </tr>
        {% endfor %}
      </table>
    </div><!-- /.box-body -->
<!--   </div> --><!-- /.box -->
</div>
</div>

{% if pagination %}
<div class="pagination">
    {{ macros.pagination_widget(pagination, '.edit') }}
</div>
{% endif %}

{%else %}
<h3><strong>你没有权限进入后台，请联系网站管理员:<a href="mailto:ifwenvlook@163.com">ifwenvlook@163.com</a></strong></h3>
{% endif %}

{% endblock %}

